<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,u ser-scalable=no">
		<link rel="stylesheet" type="text/css" href="/css/reset.css"/>
		<script type="text/javascript" src="/js/jquery-3.2.1.js"></script>
		<title>我的订单</title>
		<style type="text/css">
			.order { position: relative;width: 94%;height: 2.1rem;background: #EFEFEF;margin: 0rem auto 0.2rem;padding-top: 0.2rem;border-radius: 0.1rem; }
			.order p { font-size: 0.3rem;line-height: 0.5rem;padding-left: 0.2rem;position: relative;z-index: 2; }
			img { width: 1.8rem;position: absolute;right: 0.2rem;top: 0.2rem; }
			span { display: inline-block;position: absolute;right: 0.2rem;font-size: 0.28rem;bottom: 0.2rem; }
		</style>
	</head>
	<body>
		<br />
		<div id="coupon">
		</div>
	</body>
	<script type="text/javascript">
	var coupon = "";
	init();
	function init(){
		$.ajax({
			async:false,
			url:"/coupon/selectListByPhone",
			type : 'get',
			dataType:'json',
			success : function(rs) {

				if(rs.code==200){
					coupon = "";
					$.each(rs.data,function(index,item){
						coupon =coupon + "<div class=\"order\">"+
											"<p>优惠券："+item.name+"</p>"+
											"<p>开始日期: "+dateFormat(item.begin)+"</p>"+
											"<p>结束日期："+dateFormat(item.end)+"</p></div>";
											//+"<p>"+item.discount+" 卷</p>"
					});
						$("#coupon").html(coupon);
				}else{
					location.href='customerPhone'
				}
			},error:function(data){alert(data);}
		});
	}


	function datetimeFormat(longTypeDate){
		 var dateTypeDate = "";
		 var date = new Date();
		 date.setTime(longTypeDate);
		 dateTypeDate += date.getFullYear(); //年
		 dateTypeDate += "-" + getMonth(date); //月
		 dateTypeDate += "-" + getDay(date); //日
		 dateTypeDate += " " + getHours(date); //时
		 dateTypeDate += ":" + getMinutes(date);  //分
		 dateTypeDate += ":" + getSeconds(date);  //分
		 return dateTypeDate;
		}
		/*
		 * 时间格式化工具
		 * 把Long类型的1527672756454日期还原yyyy-MM-dd格式日期
		 */
		function dateFormat(longTypeDate){
		 var dateTypeDate = "";  
		 var date = new Date();  
		 date.setTime(longTypeDate);  
		 dateTypeDate += date.getFullYear(); //年  
		 dateTypeDate += "-" + getMonth(date); //月  
		 dateTypeDate += "-" + getDay(date); //日  
		 return dateTypeDate; 
		}  
		//返回 01-12 的月份值  
		function getMonth(date){  
		 var month = "";  
		 month = date.getMonth() + 1; //getMonth()得到的月份是0-11  
		 if(month<10){  
		  month = "0" + month;  
		 }  
		 return month;  
		}  
		//返回01-30的日期  
		function getDay(date){  
		 var day = "";  
		 day = date.getDate();  
		 if(day<10){  
		  day = "0" + day;  
		 }  
		 return day;  
		} 
	</script>
</html>
